package com.pansoft.openplanet.activity;

import com.efounder.chat.activity.BaseActivity;
import com.pansoft.openplanet.widget.TCLoadingDataView;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * 淘米baseactivity
 * Created by will on 18-3-20.
 */

public class TCBaseActivity extends BaseActivity {
    @Override
    public void showLoading(String text) {
        TCLoadingDataView.show(this, text);
    }

    @Override
    public void showLoading(int msg) {
        TCLoadingDataView.show(this, msg);
    }

    @Override
    public void dismissLoading() {
        if (!isDestroyed()) {
            TCLoadingDataView.dismiss();
        }
    }

    private CompositeDisposable compositeDisposable;

    public void addDisposable(Disposable disposable) {
        if (compositeDisposable == null) {
            compositeDisposable = new CompositeDisposable();
        }
        if (disposable != null) {
            compositeDisposable.add(disposable);
        }

    }

    public void dispose() {
        if (compositeDisposable != null) {
            compositeDisposable.dispose();
        }
        compositeDisposable = null;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        dispose();
    }
}
